package cate.game.fight.msg;

import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdBFight;
import easy.java.dev.note.NoteField;

import java.util.ArrayList;
import java.util.List;

@ClientMsg(title = "计算怪物战力 の 请求")
public class CalInsPowerReq implements MsgInput {

    @NoteField("怪物配置code")
    public List<String> codes = new ArrayList<>();

    @NoteField("动态英雄等级")
    public List<Integer> heroLevels;

    @NoteField(value = "key值",detail = "区分是哪一组怪")
    public int key;

    @Override
    public void execute(GameBody game, ClientContext cc) {
        CalInsPowerResp resp = new CalInsPowerResp();
        resp.key = key;
        boolean needDynLevel = heroLevels != null && heroLevels.size() == codes.size();
        for (int i = 0; i < codes.size(); i++) {
            String code = codes.get(i);
            if (needDynLevel) {
                resp.add(game.power.calByDynCode(code, heroLevels.get(i)));
            } else {
                resp.add(game.power.calByDynCode(code));
            }
        }
        cc.getRole().sendNow(resp);
    }

    @Override
    public MsgConfig conf() {
        return MsgIdBFight.INS_POWER_REQ;
    }
}
